﻿using SaaS.Model.Entity.Logs;
using System;
using System.Collections.Generic;
using System.Text;
using XCore.Logger;
using XCore.Timer;
using XCore.Extensions;
using SaaS.Core;

namespace SaaS.Scheduler
{
    public class SchedulerLogger : LoggerBase
    {
        public string Name
        {
            get { return typeof(SchedulerLogger).FullName; }
        }
        public SchedulerLogger() : base(CoreSetting.LogConnectionString, typeof(SchedulerLog).GetTableName())
        {
        }

        public void Log(TimeServiceWriteModel model)
        {
            LoggerInfo ei = new LoggerInfo();
            ei.Message = model.Message;
            ei.Properties["Name"] = model.Name;
            ei.Properties["Count"] = model.Count;
            ei.Properties["Duration"] = model.Duration;
            this.DbLog(ei);
        }

        public void Log(string message)
        {
            this.Log(new TimeServiceWriteModel(this.Name, message, 0, DateTime.Now, 0));
        }
    }
}
